<h1>News Archives</h1>

<?php

    if ( $archives_list )
    {
        echo "<ul>";
        foreach( $archives_list as $archive )
        {
            echo "<li>".link_to($archive['publish_date_full'],
                        'archives/'.$archive['publish_year'].'/'.$archive['publish_month']).
                " ({$archive['total']})</li>";
        }
        echo '</ul>';
    }

?>



<?php
if ($articles_pager) 
{
    echo "<h2>Archives For $archive_date</h2>";
    $articles_parts = $articles_pager->RenderParts(10);
    $header         = $articles_parts['header'];
    $footer         = $articles_parts['footer'];
    $record_count   = $articles_parts['record_count'];
    $articles       = $articles_parts['grid'];
    if ( $record_count > 0 )
    {
        foreach( $articles as $article )
        {
            $admin_link = '';
            if ( $is_logged_in )
            {
                $admin_link = link_to('Edit',
                                      array('controller'=>'admin/news' ,'action'=>'modify?from_edit=1&id='.$article['id']));                                      
            }
            // split content by more if its there.
            if ( strstr($article['content'],'<!--more-->') !== false)
            {
                $econtent = explode('<!--more-->',$article['content']);
                $more_link = "<br>".link_to("Full Story &raquo;",
                                        array('controller'=>'news' ,
                                              'action'=>'read/'.$article['index_name'].'#read_more'));
                $article['content'] = $econtent[0].$more_link;                
            }
            printf("<div class='news_story'>
                        <h2 class='news_story_title'><span class='news_date'>%s</span> %s</h2>
                        <div class='news_story_body'>%s</div>
                        %s
                    </div>",
                    date_format($article['publish_date']),
                    link_to($article['title'],array('controller'=>'news' ,'action'=>'read/'.$article['index_name'])),
                    $article['content'],  
                    $admin_link);
        }
        echo "<p>$footer $header</p>";
    } else {
        echo "<p>No articles.</p>";
    }
}
?>